using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Main;

namespace AtletIS.Database.Mapping.Main
{
    public class ClubMap : EntityTypeConfiguration<Club>
    {
        public ClubMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.Name)
                .HasMaxLength(100);

            this.Property(t => t.City)
                .HasMaxLength(100);

            this.Property(t => t.Street)
                .HasMaxLength(100);

            this.Property(t => t.Phone)
                .HasMaxLength(100);

            this.Property(t => t.Email)
                .HasMaxLength(100);

            this.Property(t => t.Web)
                .HasMaxLength(100);

            this.Property(t => t.ClubsGroupsID)
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("Clubs");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.Street).HasColumnName("Street");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Web).HasColumnName("Web");
            this.Property(t => t.ClubsGroupsID).HasColumnName("ClubsGroupsID");
            this.Property(t => t.Active).HasColumnName("Active");
            this.Property(t => t.Sync).HasColumnName("Sync");
            this.Property(t => t.Modified).HasColumnName("Modified");

            // Relationships
            this.HasOptional(t => t.ClubsGroup)
                .WithMany(t => t.Clubs)
                .HasForeignKey(d => d.ClubsGroupsID);

        }
    }
}
